<template>
  <el-dialog
    v-model="centerDialogVisible"
    width="30%"
    align-center
    color="white"
    style="    background-color: rgba(5, 58, 109, 0.43);
    border: 5px solid rgb(161, 191, 57);"
  >
    <h1 style="color: white; margin-top: -9%">上传头像</h1>

    <el-upload
      class="upload-demo"
      drag
      action="http://101.33.228.125:8777/api/changcover"
      multiple
    >
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      <div class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
    </el-upload>
  </el-dialog>
</template>
<script>
export default {
  name: "ChangCover",
  data() {
    return {
      centerDialogVisible: false,
    };
  },
  methods: {
    //作用：限制头像上传成功后再执行刷新头像方法
    getchangecover() {
      this.$axios.get("/changcovercode").then((resp) => {
        console.log(resp.data.code);
        if (resp.data.code == 200) {
          this.$emit("getchangecover");
          console.log("执行了getchangecover");
        }
      });
    },
  },
  updated: function () {
    this.getchangecover();
  },
};
</script>
<style scoped>
.el-dialog__body {
  /* padding: calc(var(--el-dialog-padding-primary) + 10px) var(--el-dialog-padding-primary); */
  color: var(--el-text-color-regular);
  font-size: var(--el-dialog-content-font-size);
  word-break: break-all;
}
</style>